|
In computer programming, DLL injection is a technique used for running code within the address space of another process by forcing it to load a dynamic-link library. DLL injection is often used by external programs to influence the behavior of another program in a way its authors did not anticipate or intend.〔 For example, the injected code could hook system function calls, or read the contents of password textboxes, which cannot be done the usual way. A program used to inject arbitrary code into arbitrary processes is called a DLL injector. ==Approaches on Microsoft Windows== There are multiple ways on Microsoft Windows to force a process to load and execute code in a DLL that the authors did not intend: * DLLs listed in the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs are loaded into every process that loads User32.dll when that DLL attaches itself to the process.〔 Beginning with Windows Vista, AppInit_DLLs are disabled by default.〔(AppInit_DLLs in Windows 7 and Windows Server 2008 R2 )〕 Beginning with Windows 7, the AppInit_DLL infrastructure supports code signing.* DLLs listed under the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\AppCertDLLs are loaded into every process that calls the Win32 API functions CreateProcess, CreateProcessAsUser, CreateProcessWithLogonW, CreateProcessWithTokenW and WinExec.* Process manipulation functions such as CreateRemoteThread can be used to inject a DLL into a program after it has started.〔〔〔(【引用サイトリンク】title=InjectDLL )〕 *# Open a handle to the target process. This can be done by spawning the process〔 〕〔 〕 or by keying off something created by that process that is known to exist – for instance, a window with a predictable title, or by obtaining a list of running processes and scanning for the target executable's filename. *# Allocate some memory in the target process, and the name of the DLL to be injected is written to it.〔 *#: This step can be skipped if a suitable DLL name is already available in the target process. For example, if a process links to ‘User32.dll’, ‘GDI32.dll’, ‘Kernel32.dll’ or any other library whose name ends in ‘32.dll’, it would be possible to load a library named ‘32.dll’. This technique has in the past been demonstrated to be effective against a method of guarding processes against DLL injection. *# Create a new thread in the target process with the thread's start address set to be the address of LoadLibrary and the argument set to the address of the string just uploaded into the target.〔 *#: Instead of writing the name of a DLL-to-load to the target and starting the new thread at LoadLibrary, one can write the code-to-be-executed to the target and start the thread at that code.〔 *# The operating system will now call DllMain in the injected DLL.〔 *: Note that without precautions, this approach can be detected by the target process due to the DLL_THREAD_ATTACH notifications sent to every loaded module as a thread starts.〔 * Windows hooking calls such as SetWindowsHookEx.〔〔〔 * Use the SuspendThread or NtSuspendThread function to suspend all threads, and then use SetThreadContext or NtSetContextThread function to modify an existing thread's context in the application to execute injected code, that in turn could load a DLL.〔〔(【引用サイトリンク】title=SetThreadContext DLL Injection )〕 * Exploit design limitations in Windows and applications that call the LoadLibrary() function without specifying a full-qualified path to the DLL being loaded. * Operating system-level shims. * Substituting an application-specific DLL with a rogue replacement that implements the same function exports as the original. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「DLL injection」の詳細全文を読む スポンサード リンク
|